import 'package:flutter/material.dart';
import 'package:flutter_app/components/layout.dart';
import '../../components/BottomSheetModal.dart';
import 'package:flutter_app/generated/l10n.dart';

class WarningPage extends StatefulWidget {
  @override
  _WarningPageState createState() => _WarningPageState();
}

Widget WarnItem(context, String text,
    {bool isOk, String okImg, String notokImg, Function onPressed}) {
  return RowBetween(
    children: [
      Row(
        children: [
          Image.asset(
            isOk ? okImg : notokImg,
            width: 25,
          ),
          SizedBox(
            width: 15,
          ),
          Text(
            text,
            style: TextStyle(
                fontWeight: FontWeight.w500,
                fontSize: 16,
                color: isOk ? Colors.black : Colors.grey),
          ),
        ],
      ),
      Row(
        children: [
          Offstage(
              offstage: !isOk,
              child: Container(
                  alignment: Alignment.center,
                  width: 60,
                  child: Image.asset('assets/images/ic_had_set_blue.png',
                      width: 25))),
          Offstage(
            offstage: isOk,
            child: FlatButton(
              onPressed: onPressed ?? () {},
              minWidth: 60,
              height: 30,
              textColor: Colors.blueAccent,
              color: Colors.blue.withOpacity(0.08),
              child: Text(S.of(context).set), //设置
            ),
          )
        ],
      ),
    ],
  );
}

class _WarningPageState extends State<WarningPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DarkHeadBar(S.of(context).withdraw_warn),
      body: Padding(
          padding: EdgeInsets.symmetric(horizontal: 20.0),
          child: Column(
            children: [
              Container(
                  margin: EdgeInsets.symmetric(vertical: 30.0),
                  child: Text(
                    S.of(context).withdraw_tip,
                    style: TextStyle(color: Colors.grey),
                  )),
              Wrap(runSpacing: 45.0, children: [
                //手机
                WarnItem(context, S.of(context).phone,
                    okImg: 'assets/images/ic_withdraw_phone_p.png',
                    notokImg: 'assets/images/ic_withdraw_phone.png',
                    isOk: true),
                //邮箱
                WarnItem(context, S.of(context).mail,
                    okImg: 'assets/images/ic_withdraw_email_p.png',
                    notokImg: 'assets/images/ic_withdraw_email.png',
                    isOk: false,
                    onPressed: () => BottomSheetModal.setMail(context)),
                //identity 身份认证
                WarnItem(context, S.of(context).identity,
                    okImg: 'assets/images/ic_withdraw_kyc_p.png',
                    notokImg: 'assets/images/ic_withdraw_kyc.png',
                    isOk: true),
                //资金密码
                WarnItem(context, S.of(context).fund_psw,
                    okImg: 'assets/images/ic_withdraw_fund_pwd_p.png',
                    notokImg: 'assets/images/ic_withdraw_fund_pwd.png',
                    isOk: false,
                    onPressed: () => BottomSheetModal.setFundPsw(context))
              ]),
            ],
          )),
    );
  }
}
